const http = require('http');
 
const server = http.createServer((request, response) => {
    //获取请求的方法
    let {method} = request; //解构赋值等同于let method = request.method;
    //获取请求的url路径
    let {pathname} = new URL(request.url,'http://127.0.0.1'); //构造URL
    response.setHeader('content-type','text/html;charset=utf-8')
    console.log(method);
    console.log(pathname);
    if (method === 'GET' && pathname === '/login'){
        response.end('登录页面');
    }
    else if (method === 'GET' && pathname === '/reg'){
        response.end('注册页面');
    }
    else{
        response.end('404 NOT FOUND');
    }
});
 
server.listen(9000, () => {
    console.log("Start, 9000 is been listened");
});